package collection;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListDemo {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("1");
        list.add("2");
        list.add("3");
        list.add("4");
        list.add("5");
        list.add("1");

        System.out.println(list);
        String str = list.get(2);
        System.out.println(str     );

        /*for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }

        for (String s:list){
            System.out.println(s);
        }

        Iterator<String> it = list.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }*/

        String str1 = list.set(2,"6");
        System.out.println(str1);
        System.out.println(list);

        String str2 = list.remove(2);
        System.out.println(str2);
        System.out.println(list);

        list.add(3,"7");
        System.out.println(list);






    }
}
